package com.example.evanjames.animationtest;

import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

public class MainActivity extends Activity {

    private static int count = 0;
    private MyAnimView snowView;
    private MediaPlayer mMediaPlayer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);  //无title
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main);
        AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        if((mAudioManager.getStreamVolume( AudioManager.STREAM_MUSIC ) < 3))
        {
            Toast.makeText(this,"音量太小了哦！", Toast.LENGTH_LONG).show();
        }
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        snowView = (MyAnimView) findViewById(R.id.mysnow);

    }

    @Override
    protected void onResume() {
        super.onResume();
        mMediaPlayer = MediaPlayer.create(this, R.raw.happy);
        mMediaPlayer.setLooping(true);
        mMediaPlayer.start();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mMediaPlayer.stop();
    }
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if(event.getAction() == MotionEvent.ACTION_DOWN) {
            count++;
            switch (count) {
                case 1:
                    Toast.makeText(this, "点我！", Toast.LENGTH_SHORT).show();
                    break;
                case 11:
                    Toast.makeText(this, "叫你点我！", Toast.LENGTH_SHORT).show();
                    break;
                case 21:
                    Toast.makeText(this, "还真的点我！", Toast.LENGTH_SHORT).show();
                    break;
                case 31:
                    Toast.makeText(this, "继续点我！", Toast.LENGTH_SHORT).show();
                    break;
                case 41:
                    Toast.makeText(this, "我只是", Toast.LENGTH_SHORT).show();
                    break;
                case 51:
                    Toast.makeText(this, "想跟你说声", Toast.LENGTH_SHORT).show();
                    break;
                case 91:
                    Toast.makeText(this, "圣诞快乐!", Toast.LENGTH_LONG).show();
                    break;
                case 100:
                    count = 0;
                    break;
            }
        }
        return super.onTouchEvent(event);
    }
}
